package com.medicine.hbp.adapter;

import org.kymjs.kjframe.KJBitmap;

import com.medicine.hbp.base.MyBaseAdapter;
import com.medicine.hbp.mob.laberInfoVo;
import com.medicine.hbp.xListView.XListView;
import com.medicine.hbp.R;

import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.TextView;

public class ClassificationAdapter extends MyBaseAdapter {
	private LayoutInflater inflater;
	private KJBitmap bitmap=new KJBitmap();

	public ClassificationAdapter(Activity activity) {
		this.activity=activity;
		inflater = LayoutInflater.from(activity);
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		viewHolder holder = null;
		if (view == null) {
			holder = new viewHolder();
			view = inflater.inflate(R.layout.item_classification, null);
			holder.text_b_title = (TextView) view.findViewById(R.id.text_b_title);
			holder.text_b_content = (TextView) view.findViewById(R.id.text_b_content);
			holder.text_num_nr = (TextView) view.findViewById(R.id.text_num_nr);
			holder.text_num_pl = (TextView) view.findViewById(R.id.text_num_pl);
			holder.text_num_gz = (TextView) view.findViewById(R.id.text_num_gz);
			holder.img_bq = (ImageView) view.findViewById(R.id.img_bq);
			holder.img_sy = (ImageView) view.findViewById(R.id.img_sy);
			view.setTag(holder);
		} else {
			holder = (viewHolder) view.getTag();
		}
		laberInfoVo infoVo = (laberInfoVo) getItem(position);
		if (infoVo != null) {
			holder.text_b_title.setText(infoVo.laberName);
			holder.text_b_content.setText(infoVo.laberNote);
			holder.text_num_nr.setText(infoVo.laberArtNumber + "内容");
			holder.text_num_pl.setText(infoVo.laberDiscussNumber + "评论");
			holder.text_num_gz.setText(infoVo.laberAttNumber + "关注");
			if(TextUtils.isEmpty(infoVo.laberImg)){
				bitmap.display(holder.img_bq, "");
			}else{
				bitmap.display(holder.img_bq, infoVo.laberImg);
			}
			if(TextUtils.isEmpty(infoVo.laberLogo)){
				bitmap.display(holder.img_sy, "");
			}else{
				bitmap.display(holder.img_sy, infoVo.laberLogo);
			}

		}
		return view;
	}

	class viewHolder {
		TextView text_b_title;// 标题
		TextView text_b_content;// 内容
		TextView text_num_nr;// 内容数量
		TextView text_num_pl;// 评论数量
		TextView text_num_gz;// 关注数量
		ImageView img_bq;
		ImageView img_sy;
	}

}
